package com.sxpi.course.controller;

import com.sxpi.common.result.R;
import com.sxpi.course.service.chapterlesson.IChapterLessonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 董伟豪
 * @Date: 2022/10/13 14:54
 */
@RestController
@Slf4j
public class ChapterLessonController {

    @Autowired
    private IChapterLessonService chapterLessonService;

    /**
     * 根据课程id查询对应章节的信息
     * @param courseId 课程id
     * @return
     */
    @PostMapping("/course/chapterlesson/{courseId}")
    public R getChapterLessonDetail(@PathVariable("courseId")Long courseId){
        return R.ok().put("chapterLessons",chapterLessonService.getChapterLessonDetail(courseId));
    }

    /**
     * 根据课程id查询对应章节的信息（去除空字段）
     * @param courseId
     * @return
     */
    @PostMapping("/course/chapterlessonmap/{courseId}")
    public R getChapterLessonDetailMap(@PathVariable("courseId")Long courseId){
        return R.ok().put("chapterLessons",chapterLessonService.getChapterLessonDetailMap(courseId));
    }
}

